In [1]:
push!(LOAD_PATH,"../src")
using Laplacians
In [2]:
n = 10;
A = randRegular(n,5)
A = triu(A);
full(A)
Out[2]:
In [3]:
rInd = randperm(n);
rA = A[rInd,rInd];
full(rA)
Out[3]:
In [4]:
B = dirEdgeVertexMat(A)';
B'*collect(1:n) .< 0
Out[4]:
In [5]:
B = dirEdgeVertexMat(rA)';
B'*collect(1:n) .< 0
Out[5]:
Let's figure out how to first see that mat a is a DAG, then sort it in a way that proves it, (orig order should work), then sort it in a way that's not a topological sort, then use toposort to get back another topoorder.
In [6]:
topoOrd = toposort(A)
Out[6]:
In [7]:
Atopo = A[topoOrd,topoOrd];
Btopo = dirEdgeVertexMat(Atopo)';
In [8]:
Btopo'*collect(1:n) .< 0
Out[8]:
In [16]:
rtopoOrd = toposort(rA);
rAtopo = rA[rtopoOrd,rtopoOrd];
rBtopo = dirEdgeVertexMat(rAtopo)';
rBtopo'*collect(1:n) .< 0
Out[16]:
good!
Now, let's try a graph that doesn't have a topoOrder, just to make sure?
In [47]:
uA = randRegular(n,5)
utopoOrd = toposort(uA');
uAtopo = uA[utopoOrd,utopoOrd];
uBtopo = dirEdgeVertexMat(uAtopo')';
uBtopo'*collect(1:n) .< 0
Out[47]:
good, there'd be something wrong if all edges respected the non-existent topo order?